import java.util.Random;

public abstract class Equation {
    private final int NUM_MIN =0;
    private final int NUM_MAX =100;
    private final int RESULT_MIN =0;
    private final int RESULT_MAX =100;
    private int leftNum;
    private int rightNum;
    private int result;
    private String op;

    public int getLeftNum() {
        return leftNum;
    }

    public void setLeftNum(int leftNum) {
        this.leftNum = leftNum;
    }

    public int getRightNum() {
        return rightNum;
    }

    public void setRightNum(int rightNum) {
        this.rightNum = rightNum;
    }

    public int getResult() {
        return result;
    }

    public void setResult(int result) {
        this.result = result;
    }

    public String getOp() {
        return op;
    }

    public void setOp(String op) {
        this.op = op;
    }

    @Override
    public String toString() {
         return this.leftNum + op + this.rightNum + "=";
    }

    public int generateRandom(int min, int max) {
        Random random = new Random();
        return random.nextInt(max-min+1)+min;

    }
    public boolean isBetween(int value,int min, int max) {
        return value >= min && value <= max;
    }

    protected  abstract int calculate();
    public  Equation(){

    }

    public Equation(String op) {
        do {
            leftNum = generateRandom(NUM_MIN,NUM_MAX);
            rightNum = generateRandom(NUM_MIN,NUM_MAX);
            result = calculate();
        }while (!isBetween(result,RESULT_MIN,RESULT_MAX));
    this.op = op;
    }

}
